Check a toggle

Hi,

I have a script that creates some metrics for all objects from a module and I want to put a checkbox , to be able to create metrics also for the filtered objects, not only for the entire module.

So I created another function that analyses the objects from the current view.

Now I have two functions:

 1. calcMetrics = for the entire module

 2. calcMetrics_2 = for objects in current view

and I want to check if the checkbox is true then apply the calcMetrics_2 function and if not, apply the calcMetrics function.

This part of the code is:

DBE selectobj = toggle(db, "Objects in current view", true)

bool check = get selectobj
if (check==false) apply(db, "Update report", calcMetrics)
 else apply(db, "Update report", calcMetrics_2)

But the result is not the expected one. If is checked, it will return the right report, but if I uncheck it, the result is the same, only for the objects in that view.

I am a really beginner in DXL and I don't know how to do this :)

Can anyone give me an idea ?

Thanks


Lari_me - Mon Jul 03 06:04:32 EDT 2017

Re: Check a toggle
Mathias Mamsch - Mon Jul 03 08:05:23 EDT 2017

With apply you set the callback that will be executed, when the user presses a button. Inside the callback you Need to get the value of the Checkbox: 

DBE selectobj = toggle(...); 

void calcMetrics(DBE) {
    bool check = get selectobj; 
    if (!check) ...
    else ...
}

apply(db, "UpdateReport", calcMetrics)

Maybe like the above (without checking the Code). Hope that helps,  regards, Mathias

Re: Check a toggle
Lari_me - Thu Jul 06 07:55:05 EDT 2017

Hi Mathias,

It worked, thank you very much for your reply :)

 

Best regards

Cosmina